package ictbk.ttmk51.grapro.app.utils;

public class ConvertBitToByteUnit {
	public static double round( double value, int fractionDigits)
	{
	           double d = Math.pow( 10, fractionDigits ) ;

	           return( Math.round( value * d ) / d ) ;
	}
	public static String convertByteToKiloMegaByte(long bytes){
		long result = 0;
		if(bytes <= 1048576){
			result = (long)(bytes/1024); // Convert from bytes to kilobytes
			return String.valueOf((long)(round(result, 5))) + "Kb";
		}else{
			result = (long)(bytes/1048576); //Convert from bytes to Megabytes
			return String.valueOf((long)(round(result, 5))) + "Mb";
		}
		
	}
}
